package com.example.mrjiangprogressbar;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;

public class MainActivity extends AppCompatActivity {
    private  LingProgressBar lingProgressBar;
    private JiKeProgressBar jiKeProgressBar;
    private  SecondProgressBar secondProgressBar;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        lingProgressBar=findViewById(R.id.LIngPB);
        lingProgressBar.setClickable(true);
        lingProgressBar.setJump(true);

        jiKeProgressBar=findViewById(R.id.pb);
        jiKeProgressBar.setJump(true);
        jiKeProgressBar.setClickable(true);

        secondProgressBar=findViewById(R.id.SecondProgressBar);
       // secondProgressBar.setJump(true);
        secondProgressBar.setClickable(true);

        new Thread(new Runnable() {
            @Override
            public void run() {
                for (int i=0;i<100;i++){
                    try {
                        Thread.sleep(200);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                    final int I=i;
                    runOnUiThread(new Runnable() {
                        @Override
                        public void run() {
                           lingProgressBar.setRatio(I/100.0f);
                           jiKeProgressBar.setRatio(I/100.0f);
                           secondProgressBar.setRatio(I/100.0f);

                        }
                    });
                }
            }
        }).start();
    }
}
